| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 1 |
| 1 | "use strict"; |
||
| 52 | function parseConfig(configStr) { |
||
| 53 | var config = {}; |
||
| 54 | var lines = configStr.split(/\r?\n/); // Split lines |
||
| 55 | var lastCellLine = lines[0].split(' '); // Save first line |
||
| 56 | var mowersLines = lines.splice(1, lines.length-1); // Array of mowers |
||
| 57 | config.topRightPos = {x:parseInt(lastCellLine[0]), y:parseInt(lastCellLine[1])}; // Define first line in config object |
||
| 58 | config.mowers = []; |
||
| 59 | for(var i=0; i<mowersLines.length; i++) { |
||
| 60 | if(i%2){ |
||
| 61 | var position = mowersLines[i-1].split(' '); |
||
| 62 | config.mowers.push({ |
||
| 63 | pos:{x:parseInt(position[0]), y:parseInt(position[1])}, |
||
| 64 | cardinal:position[2], |
||
| 65 | instructions:mowersLines[i].split('') |
||
| 66 | }); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | return config; |
||
| 70 | } |
||
| 71 |